package oakclub.entity;

import oakclub.global.Container;
import oakclub.service.PhotoService;

import java.util.Date;

public class PhotoEntity extends BaseEntity
{
    private int id;
    private UserEntity user;
    private String path;
    private boolean isAvatar;
    private Date createdTime;

    public PhotoEntity()
    {

    }

    public PhotoEntity(String path)
    {
        this.path = path;
    }

    public PhotoEntity(UserEntity user, String path)
    {
        this.user = user;
        this.path = path;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public UserEntity getUser()
    {
        return user;
    }

    public void setUser(UserEntity user)
    {
        this.user = user;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public boolean isAvatar()
    {
        return isAvatar;
    }

    public void setAvatar(boolean isAvatar)
    {
        this.isAvatar = isAvatar;
    }

    public Date getCreatedTime()
    {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime)
    {
        this.createdTime = createdTime;
    }

    public String getUrl()
    {
        PhotoService photoService = (PhotoService) Container.getComponent(PhotoService.class);
        return photoService.getUrl(this.user.getId(), this.path);
    }
}
